import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
//题目地址：https://www.luogu.com.cn/problem/P8598
public class 错误票据 {
    public static void main(String[] args) {
        //行数
        int N;
        //集合大小
        int size = 0;
        //断号
        int unContinue = 0;
        //重号
        int repeat = 0;
        Scanner scan = new Scanner(System.in);
        N = scan.nextInt();
        String[] nums = new String[N];
        scan.nextLine();
        for (int i = 0; i < N; i++) {
            nums[i] = scan.nextLine();
            //获取数字
            String[] split = nums[i].split(" ");
            int length = split.length;
            size += length;
        }
        //创建集合，添加元素
        List<Integer> numList = new ArrayList<>(size);
        for (int i = 0; i < N; i++) {
            String[] split = nums[i].split(" ");
            int length = split.length;
            for (int j = 0; j < length; j++) {
                int num = Integer.parseInt(split[j]);
                numList.add(num);
            }
        }
        numList.sort((o1, o2) -> o1 - o2);
        //System.out.println(numList);
        //找断号和重号
        Integer[] array = numList.stream().toArray(Integer[]::new);
        for (int i = 0; i < array.length - 1; i++) {
            if (array[i + 1].equals(array[i] + 1))
                continue;
            else if (array[i + 1].equals(array[i]))
                //重号
                repeat = array[i + 1];
            else unContinue = array[i] + 1;
            //断号
        }
        //输出答案
        System.out.println(unContinue + " " + repeat);
    }
}
